<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function addText(){
				let text=document.createElement("div")
				text.innerHTML="文字节点"
				document.querySelector(".con").appendChild(text)
				
			}
			function addImg(){
				let text=document.createElement("img")
				text.setAttribute("src","src/ok.png")
				document.querySelector(".con").appendChild(text)
			}
			function delect1(){
				let text = document.querySelector(".con>div")
				text.parentNode.removeChild(text)
			}
			function delect2(){
				let text = document.querySelector(".con>img")
				text.parentNode.removeChild(text)
			}
			function delect3(){
				let text = document.querySelector(".con")
				text.removeChild(text.firstChild)
			}
			function delect4(){
				let text = document.querySelector(".con")
				text.removeChild(text.lastChild)
			}
		</script>
	</head>
	<body>
		<button type="button" onclick="addText()">添加文本</button>
		<button type="button" onclick="addImg()">添加图片</button>
		<button onclick="delect1()">删除第一个文本</button>
		<button onclick="delect2()">删除第一个图片</button>
		<button onclick="delect3()">删除第一个孩子</button>
		<button onclick="delect4()">删除最后一个孩子</button>
		<div class="con"></div>
	</body>
</html>
